package com.merge.task;

import com.common.RandomUtils;
import com.merge.pojo.Data;
import com.merge.queue.SliceQueue;
import com.merge.queue.SliceQueueManger;

public class TestSliceQueueTask extends Task {

    public TestSliceQueueTask(int id) {
        super(id, "test_slice_queue_task");
    }

    @Override
    public void run() {
        while(true) {
            try {
                SliceQueue<Data>[] queues = SliceQueueManger.sliceQueueMapToArr();
                Thread.sleep(500);
                int random = RandomUtils.random(0, 3);
                SliceQueue<Data> queue = queues[random];
                Data data = queue.poll();
                if (data == null) {
                    System.out.println("pipeQueueName:" + queue.getName() + "无数据");
                }else {
                    System.out.println("pipeQueueName:" + data.getPipelineQueueNmae() + ", value:" + data.getValue());
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
